package com.yachang.qym.usbhost.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Created by qinyuanmao on 16/9/5.
 */
public class NetConnected {
    public static boolean isConnectNet(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo Mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

        NetworkInfo Wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if (Mobile.getState().equals(NetworkInfo.State.DISCONNECTED)
                && Wifi.getState().equals(NetworkInfo.State.DISCONNECTED)) {
            return false;
        }
        return true;
    }
}
